<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <div id="app">
            <p>
                <input type="text" v-model='firstname' placeholder="姓">
            </p>
            <p>
                <input type="text" v-model='lastname' placeholder="名">
            </p>
            <p>
                <input type="text" v-model='fullname' placeholder="全名">
            </p>
        </div>

    </div>


    <script>

        var app = new Vue({
            el: '#app',
            data: {
                firstname: '',
                lastname:'',
                fullname:''
            },
            watch:{
                firstname:function(val) {
                    console.log('firstname')
                    this.fullname = val + ' ' + this.lastname
                },
                lastname:function(val) {
                    console.log('lastname')
                    this.fullname = this.firstname + ' ' +val
                }
            }
        })

        console.log('app', app)

    </script>
</body>

</html>